package summative;

import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;

public class Menu extends JMenuBar
{
	private JMenu file = new JMenu ("File");
	private JMenu help = new JMenu ("Help");
	private JMenu options = new JMenu ("Options");
	private JMenu vector = new JMenu ("Vector");
	
	private int listCounter = 1;
	private int menuListenCounter = 1;
	
	VectorList list;
	VectorFocusList fList;
	
	
	int type = 0;
	
	//match with others
	JMenuItem fileItem = new JMenuItem ("Open");
	JMenuItem saveItem = new JMenuItem("Save");
	JMenuItem exitItem = new JMenuItem("Exit");
	JMenuItem addItem = new JMenuItem("Add");
	JMenuItem subtractItem = new JMenuItem("Subtract");
	JMenuItem dotProductItem = new JMenuItem("Dot Product");
	
	AddListener addL;
	SubtractListener subL;
	DotProductListener dpL;
	SaveListener saveListener;
	
	public Menu()
	{
		super();
		this.add(file);
		this.add(options);
		this.add(vector);
		this.add(help);
		file.add(fileItem);
		file.add(exitItem);
		file.add(saveItem);
		options.add(addItem);
		options.add(subtractItem);
		options.add(dotProductItem);
		
		FileListener listener = new FileListener(fileItem, list);
		ExitListener exitL = new ExitListener(exitItem);
		saveListener = new SaveListener(saveItem, list);
		addL = new AddListener(list);
		subL = new SubtractListener(list);
		dpL = new DotProductListener(list);
		
		fileItem.addActionListener(listener);
		exitItem.addActionListener(exitL);
		saveItem.addActionListener(saveListener);
		addItem.addActionListener(addL);
		subtractItem.addActionListener(subL);
		dotProductItem.addActionListener(dpL);
	}
	
	public void setVectorList(VectorList list)
	{
		this.list = list;
	}
	
	public void addItem(JMenuItem item)
	{
		vector.add(item);
	}

}
